<%@ page pageEncoding="UTF-8"%>
<%@include file="/util/tag.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <%@include file="../common/head.jsp"%>

    <script language="javascript" type="text/javascript">
            //排序按钮的点击事件
            function sort1(btnObj) {
                if (btnObj.className == "sort_desc"){
                    btnObj.className = "sort_asc";
                    location.href="?order=base_duration&seq=asc";
                 }else{
                    btnObj.className = "sort_desc";
                    location.href="?order=base_duration&seq=desc";
                    }
                    
            }
            function sort2(btnObj) {
                if (btnObj.className == "sort_desc"){
                    btnObj.className = "sort_asc";
                    location.href="?order=base_cost&seq=asc";
                 }else{
                    btnObj.className = "sort_desc";
                    location.href="?order=base_cost&seq=desc";
                    }
                    
            }

            //启用
            function startFee(id) {
                var r = window.confirm("确定要启用此资费吗？资费启用后将不能修改和删除。");
                if(!r)	return;
                var b = request('start?id='+id,'启用成功！','启用失败!数据并发错误。',$("#operate_msg"));
                if(!b){
                	$("#operate_result_info").attr("class","operate_fail");
                	}
                document.getElementById("operate_result_info").style.display = "block";
            }
            //删除
            function deleteFee(id) {
                var r = window.confirm("确定要删除此资费吗？");
                if(!r)	return;
                var b = request('delete?id='+id,'删除成功！','删除失败!数据并发错误。',$("#operate_msg"));
                if(!b){
                	$("#operate_result_info").attr("class","operate_fail");
                	}
                document.getElementById("operate_result_info").style.display = "block";
            }
    </script>  
          
    <body>
        <%@include file="../common/top.jsp"%>

        <div id="main">
            <form action="" method="post">
                <!--排序-->
                <div class="search_add">
                    <div>
                        <input type="button" value="月租" class="sort_asc"/>
                        <input type="button" value="基费" class="sort_${order=='base_cost'?seq:'asc'}" onclick="sort2(this);" />
                        <input type="button" value="时长" class="sort_${order=='base_duration'?seq:'asc'}" onclick="sort1(this);" />
                    </div>
                    <input type="button" value="增加" class="btn_add" onclick="location.href='toAdd';" />
                </div> 
                <!--启用操作的操作提示-->
                <div id="operate_result_info" class="operate_success">
                  	<img src="../images/close.png" onclick="this.parentNode.style.display='none';location.reload();" />
                 		<span id="operate_msg">删除成功！</span>
                </div>    
                <!--数据区域：用表格展示数据-->     
                <div id="data">            
                    <table id="datalist">
                        <tr>
                            <th>资费ID</th>
                            <th class="width100">资费名称</th>
                            <th>基本时长</th>
                            <th>基本费用</th>
                            <th>单位费用</th>
                            <th>创建时间</th>
                            <th>开通时间</th>
                            <th class="width50">状态</th>
                            <th class="width200"></th>
                        </tr> 
                        									  <s:iterator value="costList">               
                        <tr>
                            <td>${id}</td>
                            <td><a href="detail?order=${order }&seq=${seq}&page=${page}&id=${id}">${name}</a></td>
                            <td>${baseDuration}</td>
                            <td><s:if test="baseCost!=null">${baseCost } 元</s:if></td>
                            <td><s:if test="unitCost!=null">${unitCost } 元/小时</s:if></td>
                            <td><s:date name="createTime" format="yyyy-MM-dd HH:mm:ss"/></td>
                            <td><s:date name="startTime" format="yyyy-MM-dd HH:mm:ss"/></td>
                            <td>${statusOptions[status]}</td>
                            <td><s:if test="status==1">                                
                                <input type="button" value="启用" class="btn_start" onclick="startFee(${id});" />
                                <input type="button" value="修改" class="btn_modify" onclick="location.href='toUpdate?order=${order }&seq=${seq}&page=${page}&id=${id}';" />
                                <input type="button" value="删除" class="btn_delete" onclick="deleteFee(${id});" />
                                </s:if>
                            </td>
                        </tr>
                        </s:iterator>  
                    </table>
                    <p>业务说明：<br />
                    1、创建资费时，状态为暂停，记载创建时间；<br />
                    2、暂停状态下，可修改，可删除；<br />
                    3、开通后，记载开通时间，且开通后不能修改、不能再停用、也不能删除；<br />
                    4、业务账号修改资费时，在下月底统一触发，修改其关联的资费ID（此触发动作由程序处理）
                    </p>
                </div>
                <!--分页-->
                <div id="pages">
                	<s:if test="page>1">
        	        <a href="?order=${order }&seq=${seq}&page=${page-1}">上一页</a>
        	        </s:if><s:else><a>上一页</a></s:else>
        	        <s:iterator begin="1" end="pageCount" var="i">
                    <a href="?order=${order }&seq=${seq}&page=${i}" 
                    <s:if test="page==#i">class="current_page"</s:if> >${i}</a>
                 </s:iterator>
                 <s:if test="page<pageCount">
        	        <a href="?order=${order }&seq=${seq}&page=${page+1}">下一页</a>
        	        </s:if><s:else><a>下一页</a></s:else>
                </div>
            </form>
        </div>
      
        <%@include file="../common/bottom.jsp"%>
    </body>
</html>
